#!/usr/bin/env bats

@test "filter around color case: 2 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11-4-Merry days will come, believe.
file11-5-Heart is [0;32mliving[0m in tomorrow;
file11:6:[01;31m[KPresent[m[K is dejected here;
file11-7-In a moment, passes sorrow;
file11-8-That which passes will be dear."
  result="$(fish -c 'tbgs Present living')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs Present oiving')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs present living')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Present Living')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Oresent living')"; [ "$result" = "$expected" ]
}

@test "filter around color case: 4 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11-2-Don't be dismal, don't be wild!
file11-3-In the day of grief, be [0;33mmild[0m
file11:4:Merry days [01;31m[Kwill[m[K come, [0;32mbelieve[0m.
file11-5-[0;34mHeart[0m is living in tomorrow;
file11-6-Present is dejected here;
file11-7-In a moment, passes sorrow;
file11:8:That which passes [01;31m[Kwill[m[K be dear."
  result="$(fish -c 'tbgs will believe mild Heart')"; [ "$result" = "$expected" ]
  expected="file11-3-In the day of grief, be [0;33mmild[0m
file11-4-Merry days [0;32mwill[0m come, [0;34mbelieve[0m.
file11:5:[01;31m[KHeart[m[K is living in tomorrow;
file11-6-Present is dejected here;
file11-7-In a moment, passes sorrow;"
  result="$(fish -c 'tbgs Heart will mild believe')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs heart will mild believe')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Heart xill mild believe')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs will believe mild heart')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs will oelieve mild Heart')"; [ "$result" = "$expected" ]
}

@test "filter around color case: 2 words partial match" {
  cd $BATS_TEST_DIRNAME
  expected="file11-4-Merry days will come, believe.
file11-5-Heart is living in tomorrow;
file11:6:[01;31m[KPres[m[Kent is [0;32mdeject[0med here;
file11-7-In a moment, passes sorrow;
file11-8-That which passes will be dear."
  result="$(fish -c 'tbgs Pres deject')"; [ "$result" = "$expected" ]
  expected="file11-4-Merry days will come, believe.
file11-5-Heart is living in tomorrow;
file11:6:[0;32mPres[0ment is [01;31m[Kdeject[m[Ked here;
file11-7-In a moment, passes sorrow;
file11-8-That which passes will be dear."
  result="$(fish -c 'tbgs deject Pres')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs pres deject')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Pres dejECt')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs deject pres')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejECt Pres')"; [ "$result" = "$expected" ]
}

@test "filter around color case: 2 words word only appears in file path" {
  cd $BATS_TEST_DIRNAME
  expected=""
  result="$(fish -c 'tbgs Pref file')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs file deject')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs the file')"; [ "$result" = "$expected" ]
}
